﻿using PortalWeb.Core.Entity;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Threading.Tasks;

namespace PortalWeb.Core.IDao
{
    public partial interface IBaseRepository<T> : IDisposable
    {
        /// <summary>
        /// 查找对象
        /// </summary>
        /// <returns></returns>
        Task<T> FindAsync(dynamic primaryId);

        /// <summary>
        /// 获取Model集合（没有Where条件）
        /// </summary>
        /// <returns></returns>
        Task<IEnumerable<T>> FindAllAsync();
        /// <summary>
        ///  实现对数据库的查询  --简单查询
        /// </summary>
        /// <returns></returns>
        Task<IEnumerable<T>> FindAsync(Expression<Func<T, bool>> predicate);

        /// <summary>
        /// 添加
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        Task<int> AddAsync(T entity);

        /// <summary>
        /// 更新
        /// </summary>
        /// <returns></returns>
        Task<T> UpdateAsync(T entity);

        /// <summary>
        /// 删除
        /// </summary>
        /// <returns></returns>
        Task<bool> DeleteAsync(T entity);

    }
}
